package com.redstar.expenses;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

@SuppressWarnings("serial")
public class Expense implements Serializable{
	
	private int ID;
	private String formattedDate;
	private String shop;
	private String item;
	private Double cost;
	private String currency;
	private int longitude;
	private int latitude;
	
	public Expense(Calendar ca, Context c){
		
		SharedPreferences myPrefs = c.getApplicationContext().getSharedPreferences("myPrefs", c.MODE_WORLD_READABLE);

		ID = -1;
		shop = "";
		item = "";
		cost = -1.0;
		currency = myPrefs.getString("CURRENCY", "USD");
		longitude = -1;
		latitude = -1;
		if(ca!=null){setTimeDate(ca);}
		
	}

	public void setID(int id){
		ID = id;

	}
	
	public int getID(){
		return ID;
	}
	
	public void setTimeDate(Calendar c) {
		// TODO Auto-generated method stub
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        formattedDate = df.format(c.getTime());	
	}
	
	public String getTimeDateString(){	       
		return formattedDate;
	}
	
	public void setShop(String sh){	       
		shop = sh;
	}
	
	public String getShop(){	       
		return shop;
	}

	public void setItem(String it){	       
		item = it;
	}
	
	public String getItem(){	       
		return item;
	}

	public void setCost(Double cs){	       
		cost = cs;
	}
	
	public double getCost(){	       
		return cost;
	}
	
	public void setTimeDateString(String dt) {
		// TODO Auto-generated method stub
		formattedDate = dt;
	}

	public String getCurrencyCode() {
		// TODO Auto-generated method stub
		return currency;
	}

	public void setCurrencyCode(String code) {
		// TODO Auto-generated method stub
		currency = code;
	}

	public int getLong() {
		// TODO Auto-generated method stub
		return longitude;
	}

	public int getLat() {
		// TODO Auto-generated method stub
		return latitude;
	}

	public void setLong(int l) {
		// TODO Auto-generated method stub
		longitude = l;
	}

	public void setLat(int l) {
		// TODO Auto-generated method stub
		latitude = l;
	}
}
